import { IFormProps, size, formItemLayout, getUploadResult, getImages, getFileList, areaOptions, getAreaList } from '../../utils/common';
import React from 'react';
import { Modal, Form, Input, Select, Upload, InputNumber, Cascader } from 'antd';
import * as api from '../../api/api';
import { FormComponentProps } from 'antd/lib/form';
export interface StoreBalanceVerifyEditProps extends FormComponentProps {
    visible: boolean,
    storeBalance?: api.SingleUserMallStoresVOStoreBalanceVO,
    onSave: (any) => void,
    onCancel: () => void,
}
class StoreBalanceVerifyEdit extends React.PureComponent<StoreBalanceVerifyEditProps, any>{
    constructor(props) {
        super(props);
    }


    componentDidMount() {
        const id = this.props.storeBalance && this.props.storeBalance.id;
        this.setState({ id: id });
    }

    ok = (e) => {
        e.preventDefault();
        this.props.form.validateFieldsAndScroll((err, form) => {
            if (!err) {
                form["id"] = this.state.id;
                this.props.onSave(form);
            }
        });
    }

    cancel = () => {
        this.props.onCancel();
    }

    render(): JSX.Element {
        const { getFieldDecorator } = this.props.form;
        const { storeBalance } = this.props;
        return (
            <Modal
                title='申请信息'
                visible={this.props.visible}
                onOk={this.ok}
                onCancel={this.cancel}
                maskClosable={true}
            >
                <Form>
                    <Form.Item label="店铺名称" {...formItemLayout}>
                        {getFieldDecorator('storeName', {
                            initialValue: storeBalance && storeBalance.storeName
                        })(<Input size={size}
                            placeholder="请输入店铺名称" readOnly />)}
                    </Form.Item>
                    <Form.Item label="结算金额" {...formItemLayout}>
                        {getFieldDecorator('balanceAmount', {
                            initialValue: storeBalance && storeBalance.balanceAmount
                        })(<InputNumber size={size}
                            placeholder="请输入结算金额" readOnly />)}
                    </Form.Item>
                    <Form.Item label="是否通过" {...formItemLayout}>
                        {getFieldDecorator('isPass', {
                            rules: [
                                {
                                    required: true,
                                    message: '请选择'
                                }
                            ],
                            initialValue: 'true'
                        })(<Select
                            placeholder="请选择"
                        >
                            <Select.Option key='true'>通过</Select.Option>
                            <Select.Option key='false'>驳回</Select.Option>
                        </Select>)}
                    </Form.Item>
                </Form>
            </Modal>)
    }
}

export default Form.create()(StoreBalanceVerifyEdit);